{include file=member.header.html}
<script type="text/javascript">
//<!CDATA[

    $(function() {
        sdcategoryInit("sdcategory");
        regionInit("region");
        $('#suplly_demand_form').validate({
            errorPlacement: function(error, element) {
                $(element).next('.field_notice').hide();
                $(element).after(error);
            },
            success: function(label) {
                label.addClass('validate_right').text('OK!');
            },
            onkeyup: false,
            rules: {
                cate_id: {
                    required: true
                },
                title: {
                    required: true
                },
                region_id: {
                    required: true
                },
                phone: {
                    required: true
                },
                name: {
                    required: true
                }
            },
            messages: {
                cate_id: {
                    required: '{$lang.cate_not_null}'
                },
                title: {
                    required: '{$lang.title_not_null}'
                },
                region_id: {
                    required: '{$lang.region_not_null}'
                },
                phone: {
                    required: '{$lang.phone_not_null}'
                },
                name: {
                    required: '{$lang.name_not_null}'
                }
            }
        });
        $("[name='type']").change(function() {
            if (this.value == 1) {
                $("[ectype='demand']").hide();
                $("[ectype='supply']").show();
            }
            else {
                $("[ectype='demand']").show();
                $("[ectype='supply']").hide();
            }
        });
    });
//]]>
function add_uploadedfile(file_data)
{
    var newImg = '<tr id="' + file_data.file_id + '" class="tatr2"><input type="hidden" name="file_id[]" value="' + file_data.file_id + '" /><td><img width="40px" height="40px" src="' + SITE_URL + '/' + file_data.file_path + '" /></td><td>' + file_data.file_name + '</td><td><a href="javascript:insert_editor(\'' + file_data.file_name + '\', \'' + file_data.file_path + '\');">{$lang.insert_editor}</a> | <a href="javascript:drop_uploadedfile(' + file_data.file_id + ');">{$lang.drop}</a></td></tr>';
    $('#thumbnails').prepend(newImg);
}
function insert_editor(file_name, file_path){
    ue.execCommand( 'inserthtml', '<img src="'+ SITE_URL +'/' + file_path + '" alt="'+ file_name + '">');
}
function drop_uploadedfile(file_id)
{
    if(!window.confirm(lang.uploadedfile_drop_confirm)){
        return;
    }

    $.getJSON('index.php?app=supply_demand&act=drop_uploadedfile&file_id=' + file_id, function(result){
        if(result.done){
            $('#' + file_id).remove();
        }else{
            alert('drop_error');
        }
    });
}
</script>
{$build_editor}
<div class="content">
    <div class="totline"></div>
    <div class="botline"></div>
    {include file=member.menu.html}
    <div id="right">
        {include file=member.curlocal.html}
        {include file=member.submenu.html}
        <div class="wrap">
            <div class="public">
                <form method="post" id="suplly_demand_form" enctype="multipart/form-data">
                    <div class="information_index">
                        <div class="add_wrap">
                            <div class="assort">
                                <p class="txt">{$lang.type}:</p>
                                <p>
                                    <input type="radio" name="type" {if $info.type eq 1 or $info.type eq 0}checked{/if} value="1" />
                                           <label>{$lang.supply}</label>&nbsp;&nbsp;
                                    <input type="radio" name="type" value="2" {if $info.type eq 2}checked{/if} />
                                           <label>{$lang.demand}</label>
                                    <span class="red">*</span>
                                </p>
                            </div>
                            <div class="assort">
                                <p class="txt">{$lang.cate}:</p>
                                <p class="select" id="sdcategory">
                                    <!-- {if $info.cate_id} -->
                                    <span class="f_l">{$info.cate_name|escape}</span>
                                    <input type="button" value="{$lang.edit}" class="edit_gcategory btn" />
                                    <select style="display:none">
                                        <option>{$lang.select_pls}</option>
                                        {html_options options=$sdcategories}
                                    </select>
                                    <!-- {else} -->
                                    <select>
                                        <option>{$lang.select_pls}</option>
                                        {html_options options=$sdcategories}
                                    </select>
                                    <!-- {/if} -->
                                    <input type="hidden" id="cate_id" name="cate_id" value="{$info.cate_id}" class="mls_sdid" />
                                    <input type="hidden" id="cate_name" name="cate_name" value="{$info.cate_name}" class="mls_sdnames" />
                                    <span class="red">*</span><span class="field_notice">{$lang.sdcate_desc}</span>
                                </p>
                            </div>
                            <div class="assort" ectype="demand" style="display:none;">
                                <p class="txt">{$lang.demand_price}:</p>
                                <p>
                                    <input type="text" class="text width_short" name="price_from" value="{$info.price_from}"/>
                                    -
                                    <input type="text" class="text width_short" name="price_to" value="{$info.price_to}"/>&nbsp;&nbsp;{$lang.yuan}
                                </p>
                            </div>
                            <div class="assort" ectype="supply">
                                <p class="txt">{$lang.price}:</p>
                                <p>
                                    <input type="text" name="price" value="{$info.price}" class="text width_short" />&nbsp;&nbsp;{$lang.yuan}</p>
                            </div>
                            <div class="assort">
                                <p class="txt">{$lang.title}:</p>
                                <p>
                                    <input type="text" name="title" value="{$info.title|escape}" class="text width7" /><span class="red">*</span></p>
                            </div>
                            <div class="assort">
                                <p class="txt">{$lang.region}:</p>
                                <p class="select" id="region">
                                    <!-- {if $info.region_id} -->
                                    <span class="f_l">{$info.region_name|escape}</span>
                                    <input type="button" value="{$lang.edit}" class="edit_region" />
                                    <select style="display:none">
                                        <option>{$lang.select_pls}</option>
                                        {html_options options=$regions}
                                    </select>
                                    <!-- {else} -->
                                    <select>
                                        <option>{$lang.select_pls}</option>
                                        {html_options options=$regions}
                                    </select>
                                    <!-- {/if} -->
                                    <input type="hidden" name="region_id" value="{$info.region_id}" class="mls_id" />
                                    <input type="hidden" name="region_name" value="{$info.region_name|escape}" class="mls_names" />
                                    <span class="red">*</span>
                                </p>
                            </div>
                            <div class="assort">
                                <p class="txt">{$lang.phone}:</p>
                                <p><input type="text" name="phone" value="{$info.phone|escape}" class="text width5" /> <span class="red">*</span></p>
                            </div>
                            <div class="assort">
                                <p class="txt">{$lang.name}:</p>
                                <p><input type="text" name="name" value="{$info.name|escape}" class="text width5" /> <span class="red">*</span></p>
                            </div>
                        </div>

                        <div class="add_bewrite">
                            <h5>{$lang.details}:</h5>
                            <div class="add_wrap">
                                <div class="editor">
                                    <div>
                                        <textarea name="content" id="description"  style="width:100%; height:300px;">
                                    {$info.content|escape}
                                        </textarea>
                                    </div>
                                    <div class="clear"></div>
                                </div>
                               
                            </div>
                            <div class="clear"></div>
							<iframe id="divComUploadContainer" src="index.php?app=comupload&act=view_iframe&id={$id}&belong={$belong}" width="500" height="46" scrolling="no" frameborder="0">
							</iframe>
              
            <div class="tdare">
    <table  width="600px" cellspacing="0" class="dataTable">
        <tbody id="thumbnails">
        <!-- {foreach from=$files_belong_demand item=file} -->
        <tr class="tatr2" id="{$file.file_id}">
        <input type="hidden" name="file_id[]" value="{$file.file_id}" />
        <td><img alt="{$file.file_name}" src="{$site_url}/{$file.file_path}" width="40px" height="40px" /></td>
        <td>{$file.file_name}</td>
        <td><a href="javascript:insert_editor('{$file.file_name}', '{$file.file_path}');">{$lang.insert_editor}</a> | <a href="javascript:drop_uploadedfile({$file.file_id});">{$lang.drop}</a></td>
        </tr>
        <!-- {/foreach} -->
        </tbody>
    </table>
</div>

				<div class="issuance"><input type="submit" class="btn" value="{$lang.submit}" /></div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
</div>
{include file=footer.html}